using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using BUS;
using Utility;

public partial class User_ChiTietDonHangKH : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadData();
        }
    }

    #region"Load data"
    private void LoadData()
    {
        try
        {
            int id = int.Parse(Request.QueryString["id"]);
            //pager.PageSize = 10;
            Criteria c = new Criteria();
            c.add(Condition.AND, tbDonHangColumns.MaDH, Condition.EQUAL, id);
            int total = 0;
            tbCTDonHangCollection ctHoaDonCollection =
                tbCTDonHangBUS.Get(c.Criter, 0, 0,
                tbCTDonHangColumns.MaDH.ToString(), OrderDirection.ASC.ToString(), out total);
            Repeater1.DataSource = ctHoaDonCollection;
            Repeater1.DataBind();
            //pager.ItemCount = total;
        }
        catch
        {
            Response.Redirect("ThongTinKhachHang.aspx");
        }

    }
    #endregion
    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem ||
         e.Item.ItemType == ListItemType.Item)
        {
            tbCTDonHang ctDonHang = (tbCTDonHang)e.Item.DataItem;
            HyperLink hyper_TenSP = (HyperLink)e.Item.FindControl("hyper_TenSP");
            tbSanPham sanPham = tbSanPhamBUS.GetByID(ctDonHang.MaSP);
            hyper_TenSP.Text = sanPham.TenSP;
            Literal lit_TongTien = (Literal)e.Item.FindControl("lit_TongTien");
            double tongtien = (ctDonHang.SoLuong * ctDonHang.DonGia);
            lit_TongTien.Text = tongtien.ToString();
        }
    }
}
